export default {
	list: [],
	children(pid = 0){
		return this.list.filter(r=>{
			return r.id % 10000 === 0 ? pid === 0 :
				(r.id % 100 === 0 ? pid === floor(r.id / 100) * 100 : 
				0 < r.id - pid < 99)
		})
	},
	range (ids = [], tree={}) {
		const range = [Object.values(tree).map(r=>r.label)]
		range[0].unshift('全部')
		if (ids[1] !== undefined) {
			const children = Object.values(tree)[ids[0]]['children']
			range[1] = Object.values(children).map(r=>r.label)
			range[1].unshift('全部')
		}
		if (ids[2] !== undefined) {
			const children = Object.values(Object.values(tree)[ids[0]]['children'])
			range[2] = Object.values(children[ids[1]].children).map(r=>r.label)
			range[2].unshift('全部')
		}
		return range
	},
	// 获取选择其实用的树形结构
	picker(pid)
	{
		const picker = [];
		for(const row of this.list){
			diff = row.id - pid
			if(diff <= 0) continue
			if(pid === 0 && diff % 10000 === 0){
				picker.push({...row, children: this.picker(row.id)})
			} else if (pid % 10000 == 0 && diff % 100 == 0 && diff < 10000){
				picker.push({...row, children: this.picker(row.id)})
			} else if (pid % 100 == 0 && diff < 100){
				picker.push({...row, children: this.picker(row.id)})
			}
		}
		return picker
	}
}
